<template>
  <div>
      <el-dialog title="奖金分配" :close-on-click-modal="false" :visible.sync="visible" v-if="visible" :fullscreen="true" @close="callback">
          <el-tabs type="card" v-model="activeName" @tab-click="handleClick" class="tabBox">
                <el-tab-pane v-if="activeName=='jigou'" label="机构奖金分配" name="jigou">
                    <jigoufzCard ref="jigoufz" @jigouChild='jigouChild'></jigoufzCard>
                </el-tab-pane>
                <el-tab-pane v-else  label="人员奖金分配" name="renyuan">
                    <renyuanfzCard ref='renyuanfz' @jigouChild='jigouChild'></renyuanfzCard>
                </el-tab-pane>
          </el-tabs>
      </el-dialog>
  </div>
</template>

<script>
import {
  getUserFlag
} from "@/api/jiangjin/jiangjinfpjjfpdjb";
import jigoufzCard from '@/views/jiangjin/jiangjinfpjjfpdjb/xincaozuo/jigoufzCard'
import renyuanfzCard from '@/views/jiangjin/jiangjinfpjjfpdjb/xincaozuo/renyuanfzCard'
export default {
    components:{
        jigoufzCard,
        renyuanfzCard
    },
    data(){
        return{
            visible:false,
            activeName:"jigou",
            row:{},
        }
    },
  created() {

  },
  methods:{
        init(row,tabType){
          
          this.activeName=tabType;
            this.visible=true;
            this.row=row;
               this.$nextTick(()=>{
                 this.$refs[this.activeName+'fz'].init(row)
                   // this.$refs.jigoufz.init(row)
                   // this.$refs.renyuanfz.init(row)
               })
        },
        handleClick(tab, event) {
            console.log(tab.name);
            if(tab.name=='jigou'){
                this.$nextTick(()=>{
                    this.$refs.jigoufz.init(this.row)
                })
            }else{
                this.$nextTick(()=>{
                    this.$refs.renyuanfz.init(this.row)
                })
            }
        },
        //机构子集传过来
        jigouChild(jigouChild){
            this.callback()
            this.$emit('refreshDataList')
        },
      //获取当前用户的状态（是不是最后一级）
      getUserFlag(){
        getUserFlag().then(res=>{
          if(res.data.data){
            //不是最后一级
            this.userIsLastLevel=false;
          }else if(res.data.data){
            //该用户是最后一级
            this.userIsLastLevel=true;
          }
        })
      },
        //关闭
        callback(){
            this.visible=false
        },
    }
}
</script>

<style>
.tabBox .el-tabs__header .el-tabs__nav .el-tabs__item{
  height: 40px;
  line-height: 40px;
  padding: 0 30px;
  font-size: 20px;
}
</style>
